const express = require('express');
const router = express.Router();

const newsCtrl = require('../controller/news')
const uploadCtrl = require('../controller/upload')
const newsValidator = require('../validator/news')


// 获取新闻列表
router.get('/newslist', newsCtrl.getNews);

//获取单条新闻
router.get('/news/:id', newsCtrl.getOneNews);

//修改单条新闻

router.put('/news/:id',newsValidator.updateNews,  newsCtrl.updateNews);
// 添加新闻
// router.post('/news', uploadCtrl.upload, uploadCtrl.uploadType(true),newsCtrl.addNews);
router.post('/news', newsValidator.addNews, newsCtrl.addNews);

//删除新闻
router.delete('/news/:id', newsCtrl.delNews);



module.exports = router;
